Hello
I've created some DXL attributes in a module to return "TRUE" based on attribute conditions of the object. These DXL attributes are intended to be coalesced into an easily reviewable Gaps view in the module with a filter already applied for any of the TRUE conditions. However, the view runs extremely slower than expected while filtering on the TRUE conditions. Scrolling does not seem to be affected. I've included some code I've written to create the DXL attributes below. Since I'm a complete noob at coding, are there more efficient ways of coding the DXL to not affect module performance? Note also the code below is from a generic base where I created a bunch of different snippets first then made specific files out of them so there are unused items in the code. To reiterate, these are Attribute DXL columns, not layout. Also, apologies in advance if I'm inserting the code here incorrectly. It's been awhile.
//DXL ATTR TO USE FOR THIS FUNCTION : Case 1
Object o
Link l
string q=null
string r=null
string s=null
for o in current Module do {
string stringToAnalyze1=o."Object Text"
string stringToAnalyze2=o."Type"
string stringToAnalyze3=o."Rationale"
string sub1="shall"
int offset=null
int length=null
bool matchCase=false
bool reverse=false
//IF Object Text contains Shall
if (findPlainText (stringToAnalyze1, sub1, offset, length, matchCase, reverse)){
//AND Type is not Derived
if (stringToAnalyze2 == "Derived"){
//AND Rationale is empty
if (stringToAnalyze3 == null){
o."Case 1" = "TRUE"
} //end of Rationale loop
} //end of Type loop
} //end of Object Text loop
} //end of do loop
Rich M - Wed May 23 16:46:55 EDT 2018 |
Re: Slow Attribute DXL Hey, I think you are misunderstanding the concept of attributedxl/layoutdxl. The script you have to write for these cases get executed once for every object in the view (and more often, depending on refresh settings etc). So in your case you execute a script that loops through all objects in the module and compares/sets values... for every object in the module. So if you have 100 objects you compare/write 10.000 values and the more objects you have the worse it gets. Also if "Case 1" is not your adxl attribute name you end up spamming its history entry by doing that.
So how do you write a "good" adxl? By using the predefined "obj" and "attrDXLName" variables. The adxl "knows" for which object it is running and sets the "Object obj" variable accordingly. it also "knows" its own attribute name, this is the "string attrDXLName".
So for example:
string szObjText = obj."Object Text""";
if(matches("shall", szObjText)){
obj.attrDXLName = "rule";
}else{
obj.attrDXLName = "";
}
This (complete) adxl would display "rule" when "shall" is part of the objects object text or empty if not.
In your case you'd have to replace the for object in module loop and just check "obj" directly. |
Re: Slow Attribute DXL Thanks for the feedback. Using your reply I was able to modify several of my DXL attributes to do what I wanted, and the module performance is much better
string stringToAnalyze1=obj."Object Text"
string stringToAnalyze2=obj."Type"
string stringToAnalyze3=obj."Rationale"
//IF Object Text contains Shall
if(matches("shall", stringToAnalyze1)){
//AND Type is Derived
if(matches("Derived", stringToAnalyze2)){
//AND Rationale is empty
if(stringToAnalyze3 == null){
obj."Case 1" = "TRUE"}
else {
obj."Case 1" = ""}
// } //end of Rationale loop
} //end of Type loop
} //end of Object Text loop
Now however, I'm also trying to add a condition for whether the object has an inlink or not and it's not working for me. I am unable to figure out how to get it to look for Object Text = shall, and an allocation attribute not empty with no inlinks. Here's what I've got so far but it's not producing what I'd like. Any ideas?
LinkRef lr = null
string s = null
string stringToAnalyze1=obj."Object Text"
string stringToAnalyze2=obj."Allocation"
//IF Object Text contains Shall
if(matches("shall", stringToAnalyze1)){
//AND Allocation is not empty
if(stringToAnalyze2 != null){
//AND no Inlink
for lr in obj <- "*" do {
s = "true"
if (s != "true") {
obj."Case 2" = "TRUE" }
else {
obj."Case 2" = "" }
}
} //end of link loop
Thanks |
Re: Slow Attribute DXL Rich M - Thu May 24 13:14:25 EDT 2018 Thanks for the feedback. Using your reply I was able to modify several of my DXL attributes to do what I wanted, and the module performance is much better
string stringToAnalyze1=obj."Object Text"
string stringToAnalyze2=obj."Type"
string stringToAnalyze3=obj."Rationale"
//IF Object Text contains Shall
if(matches("shall", stringToAnalyze1)){
//AND Type is Derived
if(matches("Derived", stringToAnalyze2)){
//AND Rationale is empty
if(stringToAnalyze3 == null){
obj."Case 1" = "TRUE"}
else {
obj."Case 1" = ""}
// } //end of Rationale loop
} //end of Type loop
} //end of Object Text loop
Now however, I'm also trying to add a condition for whether the object has an inlink or not and it's not working for me. I am unable to figure out how to get it to look for Object Text = shall, and an allocation attribute not empty with no inlinks. Here's what I've got so far but it's not producing what I'd like. Any ideas?
LinkRef lr = null
string s = null
string stringToAnalyze1=obj."Object Text"
string stringToAnalyze2=obj."Allocation"
//IF Object Text contains Shall
if(matches("shall", stringToAnalyze1)){
//AND Allocation is not empty
if(stringToAnalyze2 != null){
//AND no Inlink
for lr in obj <- "*" do {
s = "true"
if (s != "true") {
obj."Case 2" = "TRUE" }
else {
obj."Case 2" = "" }
}
} //end of link loop
Thanks Again: if this is the code for your DXL Attributes "Case 1" and "Case 2", respectively, you should change lines like obj."Case 1" = ... to obj.attrDXLName = ... Then: I think you want to move the closing } of line 20 to line 16. In fact, you should be able to change lines 14ff. to
for lr in obj <- "*" do {
obj.attrDXLName = "TRUE"
break
}
|
Re: Slow Attribute DXL Hi Mike Thanks for the feedback. I've got the following snippet doing what I want it to do. Return TRUE in Case 2 DXL attribute for an allocated requirement with no inlink.
//DXL ATTR TO USE FOR THIS FUNCTION : Case 2
LinkRef lr = null
bool hasinlink = false
string stringToAnalyze1=obj."Object Text"
string stringToAnalyze2=obj."Allocation"
//IF Object Text contains Shall
if(matches("shall", stringToAnalyze1)){
//AND Allocation is not empty
if(stringToAnalyze2 != null){
//AND no Inlink
for lr in obj <- "*" do {
hasinlink = true
break }
if (hasinlink != true) {
obj.attrDXLName = "TRUE" }
}
}
Also, Case 1 now looks like
//DXL ATTR TO USE FOR THIS FUNCTION : Case 1
///////////////////////////
string stringToAnalyze1=obj."Object Text"
string stringToAnalyze2=obj."Type"
string stringToAnalyze3=obj."Rationale"
//IF Object Text contains Shall
if(matches("shall", stringToAnalyze1)){
//AND Type is Derived
if(matches("Derived", stringToAnalyze2)){
//AND Rationale is empty
if(stringToAnalyze3 == null){
obj.attrDXLName = "TRUE"}
else {
obj.attrDXLName = ""}
} //end of Type loop
} //end of Object Text loop
|